package grammer.objectMatcher;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;

/**
 * 
 * @author Minodor
 * 
 *         Initializes vocabulary from files - Folder Vocabulary
 */
public class Vocabulary {
	private static String line = new String();
	private static final Vector<String> locations = new Vector<String>();
	private static final File LocationsFile = new File(
			"Locations/Locations.txt");
	private static final Vector<String> objects = new Vector<String>();
	private static final File objectsFile = new File("Vocabulary/Objects.txt");

	private static final Vector<String> predicates = new Vector<String>();

	private static final File predictesFile = new File(
			"Vocabulary/Predicates.txt");
	private static BufferedReader reader;
	private static final Vector<String> times = new Vector<String>();
	private static final File timesFile = new File("Vocabulary/Times.txt");
	private static final Vector<String> weather = new Vector<String>();

	private static final File weatherFile = new File("Vocabulary/Weather.txt");

	private void genericInit(File f, Vector<String> v) {
		try {
			reader = new BufferedReader(new FileReader(f));
			while ((line = reader.readLine()) != null) {
				v.add(line);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void initAll() {
		System.out.println("Initializing data...");
		initLocations();
		initObjects();
		initPredicates();
		initTimes();
		initWeather();
		System.out.println("Data loaded");
	}

	private void initLocations() {
		genericInit(LocationsFile, locations);
	}

	private void initObjects() {
		genericInit(objectsFile, objects);
	}

	private void initPredicates() {
		genericInit(predictesFile, predicates);
	}

	private void initTimes() {
		genericInit(timesFile, times);
	}

	private void initWeather() {
		genericInit(weatherFile, weather);
	}
}
